import { createApp } from 'vue'
import './style.css'
import App from './App.vue'
import router from './router'
import  store from './store'
const app = createApp(App)
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import PanelHead from './components/panelHead.vue'


router.beforeEach((to,from) => {
 const token= localStorage.getItem('pz_token')
 //非登录页面token不存在
 if(!token && to.path!=='/login'){ 
   return '/login'
 }else if(token && to.path==='/login'){
  return '/'
}

  return true
 
});


import * as ElementPlusIconsVue from '@element-plus/icons-vue'


for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}
app.component('PanelHead',PanelHead)
app.use(ElementPlus)
app.use(router);
//store挂载
app.use(store)
app.mount('#app')